package com.lntea.jdbc.dbutils;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.dbutils.BasicRowProcessor;
import org.apache.commons.dbutils.BeanProcessor;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.ResultSetHandler;
import org.apache.commons.dbutils.handlers.BeanHandler;

public class CustomBeanProcessorDemo {
	public static void main(String[] args) throws ClassNotFoundException, SQLException {
		Map<String, String> map = new HashMap<String, String>();
		map.put("month_salary", "monthSalary");
		BeanProcessor customBeanProcessor = new BeanProcessor(map);
		ResultSetHandler<User> h = new BeanHandler<User>(User.class,new BasicRowProcessor(customBeanProcessor));
		
		QueryRunner queryRunner = new QueryRunner();
		User user = queryRunner.query(ConnectionUtil.getConnection(), "select * from user limit 1", h);
		System.out.println(user);
	}
}
